<!DOCTYPE html>
<html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>修改密码--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
    <link href="/resource/js/bstable/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="/resource/js/bstable/css/bootstrap-table.css" rel="stylesheet" type="text/css">
    <link href="/resource/css/table.css" rel="stylesheet" type="text/css">
</head>
<style>
</style>
<body style="background-color: #ecf0f5;font-family: 楷体;color: #475059;overflow: auto">
<div class="notice_main ">
    <div class="notice_check" style="padding: 16px 15px 8px 15px">
        <p>
            <label class="">订单编号：</label>
            <input type="text" id="orderUuId" class="find_input">
            <button class="check_btn" id="search">查询</button>
        </p>
        <div class="clear"></div>
    </div>
    <table id="salesReturnTables" class="salesReturnTables" lay-filter="salesReturnTables"></table>
</div>
<script type="text/html" id="operate">
    <a class="toolbarMy" lay-event="del">同意</a>
</script>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">
    var reminds;
    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            laydate = layui.laydate,
            form = layui.form;
        table.render({
            elem: '#salesReturnTables'
            , url: '/order/salesReturnTable.do' //数据接口
            , method: 'get'
            , page: true //开启分页
            , id: 'tableId'
            , limits: [10, 15, 30]
            , limit: 15
            , cols: [
                [ //表头
                    {field: 'orderUuId', title: '订单编号', 'fixed': 'left'}
                    , {field: 'userName', title: '提交用户'}
                    , {field: 'time', title: '提交时间'}
                    , {field: 'reason', title: '原因'}
                    , {title: '操作', toolbar: '#operate', 'fixed': 'right'}
                ]
            ]
        });
        //搜索
        $('#search').on('click', function () {
            active.reload()
        });
        //监听工具条
        table.on('tool(salesReturnTables)', function (obj) {
            var data = obj.data;
            console.log(data);
            if (obj.event === 'del') {
                console.log("del")
                del(data.id, data.orderId)
            }
        });

        //删除函数
        function del(id, orderId) {
            layer.confirm('是否同意此退货申请?', function (index) {
                $.ajax({
                    url: "/order/delSalesReturn.do",
                    type: "post",
                    data: {_method: "DELETE", "id": id, "orderId": orderId},
                    dataType: "json",
                    success: function (result) {
                        if (!result.status) {
                            layer.msg(result.msg, {time: 2000});
                            return false;
                        }
                        layer.msg("成功!", {time: 1000});
                        active.reload();
                    }
                });
                layer.close(index);
            })
        }

        active = {
            reload: function () {
                var orderUuId = $("#orderUuId").val();
                //执行重载
                table.reload('tableId', {
                    url: '/order/salesReturnTable.do'
                    , method: 'get'
                    , page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        orderUuId: orderUuId,
                    }
                });
            }
        };
    });
</script>

</body>
</html>